--[[
单人副本逻辑
--]]
local ExcelMap = require("excel.Map")
local CopyConfig = ExcelMap.copy
local SceneConfig = ExcelMap.scene
local Timer = require("core.Timer")
local ObjHuman = require("core.ObjHuman")
local Copy = require("copy.CopyL")
local Loss = require("copy.Loss")
local CopyHandler = require("copy.HandlerL")
local CopyDefine = require("copy.Define")

function applyCopyRoomSingle(copyID, config, uuid)
	for roomID in pairs(Copy.copyList[copyID]) do
		if Copy.roomDatas[copyID][roomID] == nil then
			Copy.roomDatas[copyID][roomID] = {onlineNum=0,startTime=Timer.now}
			Copy.copyHuman2Room[uuid] = roomID
			Copy.roomBegin(copyID, roomID)
			return roomID
		end
	end
	return nil
end

function humanBeginCopy(human, copyID, roomID,x,y)
	local copyConfig = CopyConfig[copyID]
	local mapID = copyConfig.mapList[1]
	local sceneConfig = SceneConfig[mapID]


	
	Loss.handler(human, copyConfig, copyID)	-- 扣除进入需要的消耗
	

  CopyHandler.incCopyEnterCount(human, copyID)
	
	if not x then
		x = sceneConfig.x
	end
	
	if not y then
		y = sceneConfig.y
	end
	
	ObjHuman.enterMap(human, mapID, x, y)
	return true
end

function humanEndCopy(human)
	local sceneID = human.scene_id
	local copyID = Copy.sceneID2CopyID[sceneID]
	local roomID = Copy.sceneID2Room[sceneID]
	
	local backHomeMapId, backHomeX, backHomeY = Copy.getBackHomePoint(human, copyID)
	ObjHuman.enterMap(human,backHomeMapId,backHomeX,backHomeY)
	
	-- 单人副本的话 一玩家退出副本就结束了
	Copy.copyHuman2Room[human._id] = nil
	Copy.roomClear(copyID, roomID)
end